<?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the  Academic Free License (AFL 3.0)
 * that is available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to support@zprofess.com so we can send you a copy immediately.
 *
 * @category   	Prestashop module
 * @package		Help Desk
 * @version 	1.0
 * @author 		Kurosaki <kurosaki@zprofess.com>
 * @copyright   Copyright (c) 2012 ZPROFESS. (http://zprofess.com)
 * @license    	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

include_once(dirname(__FILE__)."/classes/ZratingObject.php");
require_once(_PS_MODULE_DIR_.'zhelpdesk/lib/zprofess/ZhelpdeskadminTab.php');
class ZadminRatingListEmail extends ZhelpdeskadminTab
{

	public function __construct()
	{
		global $cookie;
		
		$this->table = 'zhelpdesk_ticket_content';
	 	$this->className = 'ZratingObject';
		$id_rating = Tools::getValue('id_zhelpdesk_ticket_rating',0);
		if (Tools::getValue('id_zhelpdesk_ticket_content')) {
			$id_rating= ZratingObject::getTicketRatingForContent (Tools::getValue('id_zhelpdesk_ticket_content'));
		}
		$this->fieldsDisplay = array(
			'id_customer_rating' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30),
			'firstname' => array('title' => $this->l('First Name'), 'width' => 200),
			'lastname' => array('title' => $this->l('Last Name'), 'width' => 200),
			'email' => array('title' => $this->l('Email'), 'width' => 300),
		);
		$this->_where = 'AND a.id_zhelpdesk_ticket_rating='.$id_rating;
		$this->_select = 'b.firstname,b.lastname,b.email';
		$this->_join = ' LEFT JOIN '._DB_PREFIX_.'customer b ON (a.id_customer_rating=b.id_customer)
						';
		$this->_group = 'GROUP BY a.id_customer_rating';
		$this->identifier = 'id_zhelpdesk_ticket_rating';
		$this->noLink = true;
		parent::__construct();
	}
	
	public function display () {
		global $currentIndex, $cookie;


		// Include current tab
		$this->getList((int)($cookie->id_lang));
		$this->displayList();
		$this->displayOptionsList();
		$this->displayRequiredFields();
//		$this->includeSubTab('display');
	} 
}
